package com.sr.recitewords.common.req;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.sr.recitewords.exception.BizException;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class BaseStateReq<T> {
    private T id;
    private List<T> ids;
    private String state;

    public List<T> getAllIds() {
        List<T> allIds = new ArrayList<>();
        if (ObjectUtils.isNotEmpty(id)) {
            allIds.add(id);
        }
        if (CollUtil.isNotEmpty(ids)) {
            allIds.addAll(ids);
        }
        if (CollUtil.isEmpty(allIds)) {
            throw new BizException("", "id或ids不能为空");
        }
        return allIds;
    }

}
